<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // 数字.toFixed(你要保留的小数位数)
        // 返回值: 字符串 
        var num = 0.1+0.2;
        console.log(num.toFixed(2));

        // if(0.1+0.2 === 0.3){
        //     console.log(666)
        // }


        var num = 0.15+0.21;
        console.log(num.toFixed(1),typeof(num.toFixed(1)));// 保留1位小数 自动四舍五入  

    </script>
</body>
</html>